.TH "frovedis::colmajor_matrix_local<T>" "" "" "" ""
.SH NAME
.PP
\f[C]frovedis::colmajor_matrix_local<T>\f[] \- A two\-dimensional dense
matrix with elements stored in column\-wise order supported by frovedis
.SH SYNOPSIS
.PP
\f[C]#include\ <frovedis/matrix/colmajor_matrix.hpp>\f[]
.SS Constructors
.PP
colmajor_matrix_local ();
.PD 0
.P
.PD
colmajor_matrix_local (size_t nrow, size_t ncol);
.PD 0
.P
.PD
colmajor_matrix_local (const \f[C]colmajor_matrix_local<T>\f[]& m);
.PD 0
.P
.PD
colmajor_matrix_local (\f[C]colmajor_matrix_local<T>\f[]&& m);
.PD 0
.P
.PD
colmajor_matrix_local (const \f[C]rowmajor_matrix_local<T>\f[]& m);
.SS Overloaded Operators
.PP
\f[C]colmajor_matrix_local<T>\f[]& operator= (const
\f[C]colmajor_matrix_local<T>\f[]& m);
.PD 0
.P
.PD
\f[C]colmajor_matrix_local<T>\f[]& operator=
(\f[C]colmajor_matrix_local<T>\f[]&& m);
.SS Public Member Functions
.PP
\f[C]rowmajor_matrix_local<T>\f[] to_rowmajor();
.PD 0
.P
.PD
\f[C]rowmajor_matrix_local<T>\f[] moveto_rowmajor();
.PD 0
.P
.PD
\f[C]colmajor_matrix_local<T>\f[] transpose () const;
.PD 0
.P
.PD
\f[C]node_local<colmajor_matrix_local<T>>\f[] broadcast();
.PD 0
.P
.PD
void debug_print ();
.SS Public Data Members
.PP
\f[C]std::vector<T>\f[] val;
.PD 0
.P
.PD
size_t local_num_row;
.PD 0
.P
.PD
size_t local_num_col;
.SH DESCRIPTION
.PP
\f[C]colmajor_matrix_local<T>\f[] is a template based non\-distributed
column\-major data storage supported by frovedis.
.PP
Although it provides a 2D column\-major storage view to the user,
internally the matrix elements are stored in 1D vector form with
additional row and column number information stored separately.
The structure of this class is as follows:
.IP
.nf
\f[C]
template\ <class\ T>
struct\ colmajor_matrix_local\ {
\ \ std::vector<T>\ val;\ \ \ \ \ //\ to\ contain\ matrix\ elements\ in\ 1D\ colmajor\ form
\ \ size_t\ local_num_row;\ \ \ //\ number\ of\ rows\ in\ 2D\ matrix\ view
\ \ size_t\ local_num_col;\ \ \ //\ number\ of\ columns\ in\ 2D\ matrix\ view
};
\f[]
.fi
.PP
A colmajor_matrix_local can be created from a rowmajor_matrix_local
object and it can be converted back to the rowmajor_matrix_local object.
Thus loading from file, saving into file etc.
interfaces are not provided for colmajor_matrix_local structure.
User may like to perform the conversion from/to rowmajor_matrix_local
structure for the same.
.SS Constructor Documentation
.SS colmajor_matrix_local ()
.PP
This is the default constructor which creates an empty colmajor matrix
with local_num_row = local_num_col = 0.
.SS colmajor_matrix_local (size_t nrow, size_t ncol)
.PP
This is the parameterized constructor which creates an empty colmajor
matrix of the given dimension (memory allocation takes place).
.SS colmajor_matrix_local (const \f[C]colmajor_matrix_local<T>\f[]& m)
.PP
This is the copy constructor which creates a new colmajor matrix by
deep\-copying the contents of the input colmajor matrix.
.SS colmajor_matrix_local (\f[C]colmajor_matrix_local<T>\f[]&& m)
.PP
This is the move constructor.
Instead of copying the input matrix, it moves the contents of the input
rvalue matrix to the newly constructed matrix.
Thus it is faster and recommended to use when input matrix will no
longer be used in a user program.
.SS colmajor_matrix_local (const \f[C]rowmajor_matrix_local<T>\f[]& m)
.PP
It accepts a rowmajor_matrix_local object and constructs an equivalent
colmajor_matrix_local object by simply changing the storage order of the
elements in input matrix.
Number of rows and number of columns will be same in both the input
matrix and constructed colmajor matrix.
.SS Overloaded Operator Documentation
.SS \f[C]colmajor_matrix_local<T>\f[]& operator= (const
\f[C]colmajor_matrix_local<T>\f[]& m)
.PP
It deep\-copies the input colmajor matrix into the left\-hand side
matrix of the assignment operator "=".
.SS \f[C]colmajor_matrix_local<T>\f[]& operator=
(\f[C]colmajor_matrix_local<T>\f[]&& m)
.PP
Instead of copying, it moves the contents of the input rvalue colmajor
matrix into the left\-hand side matrix of the assignment operator "=".
Thus it is faster and recommended to use when input matrix will no
longer be used in a user program.
.SS Public Member Function Documentation
.SS void debug_print ()
.PP
It prints the contents and other information related to the matrix on
the user terminal.
It is mainly useful for debugging purpose.
.PP
For example,
.IP
.nf
\f[C]
std::vector<int>\ v\ =\ {1,3,2,4};\ //desired\ storage
colmajor_matrix_local<int>\ m;
m.val.swap(v);
m.local_num_row\ =\ 2;
m.local_num_col\ =\ 2;
m.debug_print();\ 
\f[]
.fi
.PP
The above program will output:
.IP
.nf
\f[C]
node\ =\ 0,\ local_num_row\ =\ 2,\ local_num_col\ =\ 2,\ val\ =\ 1\ 3\ 2\ 4\ 
\f[]
.fi
.SS \f[C]colmajor_matrix_local<T>\f[] transpose ()
.PP
It returns the transposed colmajor_matrix_local of the source matrix
object.
.PP
For example,
.IP
.nf
\f[C]
std::vector<int>\ v\ =\ {1,3,2,4};
colmajor_matrix_local<int>\ m;
m.val.swap(v);
m.local_num_row\ =\ 2;
m.local_num_col\ =\ 2;
m.transpose().debug_print();\ 
\f[]
.fi
.PP
The above program will output:
.IP
.nf
\f[C]
node\ =\ 0,\ local_num_row\ =\ 2,\ local_num_col\ =\ 2,\ val\ =\ 1\ 2\ 3\ 4\ 
\f[]
.fi
.SS \f[C]rowmajor_matrix_local<T>\f[] to_rowmajor();
.PP
It converts the colmajor storage of the target matrix to a rowmajor
storage and returns the output \f[C]rowmajor_matrix_local<T>\f[] after
successful conversion.
The target colmajor storage remains unchanged after the conversion.
.SS \f[C]rowmajor_matrix_local<T>\f[] moveto_rowmajor();
.PP
If the target matrix has only a single column, then rowmajor storage and
column major storage both will be the same.
Thus instead of any conversion overhead, elements in target matrix can
simply be moved while creating the rowmajor_matrix_local object.
It is faster and recommended, only when the target matrix is no longer
be needed in a user program.
.SS \f[C]node_local<colmajor_matrix_local<T>>\f[] broadcast();
.PP
It broadcasts the source \f[C]colmajor_matrix_local<T>\f[] to all the
participating worker nodes.
After successful broadcasting, it returns a
\f[C]node_local<colmajor_matrix_local<T>>\f[] object representing the
broadcasted matrices at each worker nodes.
.PP
It is equivalent to broadcasting the matrix using frovedis global
function "frovedis::broadcast()" (explained in node_local manual).
But from performance point of view this is efficient as it avoids the
internal serialization overhead of the vector elements.
.PP
For example,
.IP
.nf
\f[C]
std::vector<int>\ v\ =\ {1,3,2,4};
colmajor_matrix_local<int>\ m;
m.val.swap(v);
m.local_num_row\ =\ 2;
m.local_num_col\ =\ 2;
auto\ bm1\ =\ m.broadcast();\ //\ faster
auto\ bm2\ =\ frovedis::broadcast(m);\ //\ slower\ (serialization\ overhead)

master\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ worker0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ worker1
\-\-\-\-\-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \-\-\-\-\-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \-\-\-\-\-
m:\ colmajor_matrix_local<int>
\ \ \ 1\ 3\ 
\ \ \ 2\ 4\ 

bm1:\ node_local<
\ \ \ \ \ colmajor_matrix_local<int>>\ \ colmajor_matrix_local<int>\ \ colmajor_matrix_local<int>
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 1\ 3\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 1\ 3
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ 4\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ 4
bm2:\ node_local<
\ \ \ \ \ colmajor_matrix_local<int>>\ \ colmajor_matrix_local<int>\ \ colmajor_matrix_local<int>
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 1\ 3\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 1\ 3
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ 4\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2\ 4
\f[]
.fi
.SS Public Data Member Documentation
.SS val
.PP
An instance of \f[C]std::vector<T>\f[] type to contain the elements of
the matrix in 1D column\-major form.
.SS local_num_row
.PP
A size_t attribute to contain the number of rows in the 2D matrix view.
.SS local_num_col
.PP
A size_t attribute to contain the number of columns in the 2D matrix
view.
.SH SEE ALSO
.PP
rowmajor_matrix_local, colmajor_matrix
